<!DOCTYPE html>
          <head>
        <meta charset="utf-8">
            
            <title>
                「macOS」用Homebrew安装Mysql | ttdevs
            </title>
            <meta content="width=device-width, initial-scale=1" name="viewport">
            <meta name="theme-color" content="#4184f3">
            
            
            <link href="/favicon.ico" rel="icon"/>
            

            <link rel="stylesheet" href="/css/highlight.light.css">
            <link rel="stylesheet" href="/css/prism-customize.css">
            <link rel="stylesheet" href="/css/nav-icon.css">
            <link rel="stylesheet" href="/css/waves.min.css">
            <link rel="stylesheet" href="/css/jquery.tocify.css">
            <link rel="stylesheet" href="/css/main.css">
            <link rel="stylesheet" href="/css/nav-indicator.css">
            
  

  
  <!-- 谷歌统计 -->
  <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-97465173-1', 'auto');
    ga('send', 'pageview');

  </script>
  
            </meta>
        </meta>
    </head>

    <body>
        <header>
            <!-- cover image or sth. -->
        </header>
        <div id="main" class="m-scene">
            
<div class="nav-wrapper">

    <div class="container">
        <nav>
            <div class="logo wave">
                <a href="/" id="logo">
                    ttdevs
                </a>
            </div>
            <div class="nav-toggle-icon" >
                <div class="material-hamburger">
                    <span>
                    </span>
                    <span>
                    </span>
                    <span>
                    </span>
                </div>
            </div>
            <div class="menu-wrapper">
                <div class="nav-indicator">
                </div>
                <ul class="menus">
                    
                     
                        <li>
                            <a class="wave " href="/">
                                首页
                            </a>
                        </li>
                     
                        <li>
                            <a class="wave " href="/archives">
                                归档
                            </a>
                        </li>
                     
                        <li>
                            <a class="wave " href="/about">
                                关于
                            </a>
                        </li>
                     
                    
                   
                </ul>
            </div>
        </nav>
    </div>
</div>
            <div class="container content">
                <div class="scene_element scene_element--fadein">
                    <div class="row">
    <div class="main">
        <article>
          
          <header class="post-header with-cover" style="background-image:url('/1970/01/01/[macOS]用Homebrew安装Mysql/cover.jpg')" >
          
          </header>
          <h1 class="post-title">「macOS」用Homebrew安装Mysql</h1>

          <section class="post-info">
            <span class="post-date">1970/01/01</span>
            
            <span class="post-category">
                <a class="article-category-link" href="/categories/技术/">技术</a>
            </span>
            
            
            <span class="post-tags">
              <ul class="post-tag-list"><li class="post-tag-list-item"><a class="post-tag-list-link" href="/tags/macOS/">macOS</a></li></ul>
            </span>
            
          </section>

          <section class="post-content">
            <h2 id="0x00-需求"><a href="/1970/01/01/[macOS]用Homebrew安装Mysql/#0x00-需求" class="headerlink" title="0x00 需求"></a>0x00 需求</h2><p>简单记录mac下mysql安装。这里需要一个前提——先安装 <a href="http://brew.sh/index_zh-cn.html" target="_blank" rel="external"><code>homebrew</code></a>，具体可以参考<a href="http://brew.sh/index_zh-cn.html" target="_blank" rel="external">这里</a>。</p>
<h2 id="0x01-安装"><a href="/1970/01/01/[macOS]用Homebrew安装Mysql/#0x01-安装" class="headerlink" title="0x01 安装"></a>0x01 安装</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line">➜  ~ brew install mysql</div><div class="line">＃ 以下为删除上个版本的遗留</div><div class="line">➜  ~ cd /usr/local/var/mysql</div><div class="line">➜  mysql git:(master) ls</div><div class="line">auto.cnf           ib_buffer_pool     mysql              server-cert.pem</div><div class="line">ca-key.pem         ib_logfile0        mysqld_safe.pid    server-key.pem</div><div class="line">ca.pem             ib_logfile1        performance_schema sys</div><div class="line">client-cert.pem    ibdata1            private_key.pem    ttdevs.local.err</div><div class="line">client-key.pem     ibtmp1             public_key.pem     ttdevs.local.pid</div><div class="line">➜  mysql git:(master) rm -rf ttdevs.local.err</div><div class="line">➜  mysql git:(master) cd ~</div><div class="line">＃ 以上为删除上个版本的遗留</div></pre></td></tr></table></figure>
<blockquote>
<p>卸载： <code>brew uninstall mysql</code></p>
</blockquote>
<h2 id="0x02-配置"><a href="/1970/01/01/[macOS]用Homebrew安装Mysql/#0x02-配置" class="headerlink" title="0x02 配置"></a>0x02 配置</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div></pre></td><td class="code"><pre><div class="line">➜  ~ /usr/local/opt/mysql/bin/mysql_secure_installation</div><div class="line"></div><div class="line">Securing the MySQL server deployment.</div><div class="line"></div><div class="line">Connecting to MySQL using a blank password.</div><div class="line"></div><div class="line">VALIDATE PASSWORD PLUGIN can be used to test passwords</div><div class="line">and improve security. It checks the strength of password</div><div class="line">and allows the users to set only those passwords which are</div><div class="line">secure enough. Would you like to setup VALIDATE PASSWORD plugin?</div><div class="line"></div><div class="line">Press y|Y for Yes, any other key for No:</div><div class="line">Please set the password for root here.</div><div class="line"></div><div class="line">New password:</div><div class="line"></div><div class="line">Re-enter new password:</div><div class="line">By default, a MySQL installation has an anonymous user,</div><div class="line">allowing anyone to log into MySQL without having to have</div><div class="line">a user account created for them. This is intended only for</div><div class="line">testing, and to make the installation go a bit smoother.</div><div class="line">You should remove them before moving into a production</div><div class="line">environment.</div><div class="line"></div><div class="line">Remove anonymous users? (Press y|Y for Yes, any other key for No) : y</div><div class="line">Success.</div><div class="line"></div><div class="line"></div><div class="line">Normally, root should only be allowed to connect from</div><div class="line">&apos;localhost&apos;. This ensures that someone cannot guess at</div><div class="line">the root password from the network.</div><div class="line"></div><div class="line">Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y</div><div class="line">Success.</div><div class="line"></div><div class="line">By default, MySQL comes with a database named &apos;test&apos; that</div><div class="line">anyone can access. This is also intended only for testing,</div><div class="line">and should be removed before moving into a production</div><div class="line">environment.</div><div class="line"></div><div class="line"></div><div class="line">Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y</div><div class="line"> - Dropping test database...</div><div class="line">Success.</div><div class="line"></div><div class="line"> - Removing privileges on test database...</div><div class="line">Success.</div><div class="line"></div><div class="line">Reloading the privilege tables will ensure that all changes</div><div class="line">made so far will take effect immediately.</div><div class="line"></div><div class="line">Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y</div><div class="line">Success.</div><div class="line"></div><div class="line">All done!</div><div class="line">➜  ~ mysql.server start</div><div class="line">Starting MySQL</div><div class="line"> SUCCESS!</div></pre></td></tr></table></figure>
<h2 id="0x03-启动停止"><a href="/1970/01/01/[macOS]用Homebrew安装Mysql/#0x03-启动停止" class="headerlink" title="0x03 启动停止"></a>0x03 启动停止</h2><ul>
<li><code>brew services start/stop mysql</code> </li>
<li><code>mysql.server start/stop</code></li>
</ul>
<p>两种方式都可以，但是不可以交叉使用，比如用 <code>brew services start mysql</code> 启动 却不能用 <code>mysql.server stop</code> 停止。</p>
<h2 id="0x04-GUI客户端"><a href="/1970/01/01/[macOS]用Homebrew安装Mysql/#0x04-GUI客户端" class="headerlink" title="0x04 GUI客户端"></a>0x04 GUI客户端</h2><ul>
<li><p><a href="http://www.sequelpro.com" target="_blank" rel="external">Sequel Pro</a></p>
<p>  免费</p>
</li>
<li><p><a href="https://www.navicat.com.cn/" target="_blank" rel="external">Navicat For Mysql</a></p>
<p>  收费</p>
</li>
</ul>
<h2 id="0x05-简单命令纪录"><a href="/1970/01/01/[macOS]用Homebrew安装Mysql/#0x05-简单命令纪录" class="headerlink" title="0x05 简单命令纪录"></a>0x05 简单命令纪录</h2><ul>
<li>登录：<code>mysql -u username -p</code></li>
<li>推出：<code>exit;</code></li>
<li>默认 <code>data</code> 目录：<code>/usr/local/var/mysql</code></li>
<li>Emoji表情的支持请使用编码：<code>utf8mb4</code></li>
<li>TODO 2016-09-07</li>
</ul>
<h2 id="0xFF-参考"><a href="/1970/01/01/[macOS]用Homebrew安装Mysql/#0xFF-参考" class="headerlink" title="0xFF 参考"></a>0xFF 参考</h2><ol>
<li><a href="https://segmentfault.com/q/1010000000475470" target="_blank" rel="external">https://segmentfault.com/q/1010000000475470</a></li>
<li><a href="http://pein0119.github.io/2015/03/25/MySQL%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%90%AF%E5%8A%A8%E9%94%99%E8%AF%AF-The-server-quit-without-updating-PID-file/" target="_blank" rel="external">http://pein0119.github.io/2015/03/25/MySQL%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%90%AF%E5%8A%A8%E9%94%99%E8%AF%AF-The-server-quit-without-updating-PID-file/</a></li>
</ol>
<p><img src="https://raw.githubusercontent.com/ttdevs/ttdevs.github.io/common/images/logo.png" alt="Create by ttdevs"></p>

          </section>
        </article>
        

       
        <div class="pager">
          
            <a class="post-prev pager-item" href="/1970/01/01/[WebSocket]使用Websocket实现消息推送(心跳)/" >
              <strong class="article-nav-caption">上一篇</strong>
              <p class="post-nav-title">「WebSocket」使用Websocket实现消息推送(心跳)</p>
            </a>
          
          
            <a class="post-next pager-item" href="/1970/01/01/[macOS]macOS安装/">
              <strong class="article-nav-caption">下一篇</strong>
              <p class="post-nav-title">「macOS」macOS安装</p>
            </a>
          
        </div>
        

         <!-- comments -->
        <div class="comment-section">
  
    


</div>

    </div>
    
    <aside>
        <div id="toc">
        </div>
    </aside>
    
</div>

                </div>
            </div>
        </div>
        <footer class="footer">
    <p>由<a href="http://hexo.io/" target="_blank">Hexo</a>强力驱动，搭载<a href="https://github.com/wayou/hexo-theme-gstyle">gstyle</a>主题</p>
    <p>
        &copy; 2017 ttdevs
    </p>
</footer>
<script src="/lib/jquery.js"></script>
<script src="/lib/waves.js"></script>
<script src="/lib/jquery-ui.js"></script>
<script src="/lib/jquery.tocify.js"></script>
<script src="/js/main.js"></script>

    </body>
</html>
